<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.log(a); // undefined
        var a = 12;

        function fn() {
            console.log(a); // 12
            a = 13;
        }
        fn();
        console.log(a); // 13
        /*
                我的分析：
                 var a;
                console.log(a); // undefined
                 function fn() {
                console.log(a);     // 12
                a = 13;
                }
                a = 12;
                fn();
                console.log(a); // 13
        */
    </script>
</body>

</html>